package com.xgxx.chendawei.system.utils.api;


import com.xgxx.chendawei.enums.ApiResponseEnum;

import java.io.Serializable;

/**
 * web层统一返回类型
 */
public class ApiResponse<T> implements Serializable {
    private static final long serialVersionUID = -1L;
    private int code = 0;

    private String msg;

    private T data;

    public ApiResponse() {

    }

    public ApiResponse(T data) {
        this.data = data;
    }

    public ApiResponse(ApiResponseEnum apiResponseEnum) {
        this.code = apiResponseEnum.getCode();
        this.msg = apiResponseEnum.getMsg();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ApiResponse{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
